
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@page import="com.tss.util.*"%>
<%@page import="com.jedi.*"%>
<%@page import="com.store.*"%>
<%@page import="java.util.*"%>
<%@page import="java.text.*"%>
<%@include file="../global_var.jsp"%>
<%@include file="../check_login.jsp"%>
<%
DownloadMgr downloadMgr = new DownloadMgr();
DownCateMgr cateMgr = new DownCateMgr();
List list = null;
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String category_id = ParamUtils.getParameter(request,"category_id","");
String keyval = ParamUtils.getParameter(request,"keyval","");
%>
<html>
<head>
   <base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<link href="style/main.css" rel="stylesheet" type="text/css">
<script language="javascript" src="js/common.js"></script>
<script language="javascript">
function clk_soft_show(soft_id) {
	location.href = "../knowledge_mgt/know_soft_show.jsp?id=" + soft_id;
}

function clk_search() {
	var sForm = document.searchForm;
	try {
		var oForm = document.pageForm;
		oForm.category_id.value = sForm.category_id.options[sForm.category_id.selectedIndex].value;
		oForm.keyval.value = sForm.keyval.value;
		oForm.submit();
	}
	catch(ex) {
		//alert(ex.description);
		sForm.submit();
	}
}
</script>
</head>
<%
String otherSQL = "";
if (category_id != null && !category_id.trim().equals("")) 
	otherSQL += " and a.category_id = '" + category_id + "'";
if (keyval != null && !keyval.trim().equals("")) 
	otherSQL += " and a.soft_name like '%" + keyval + "%'";
String orderField = "a.issue_time desc";
int pageSize = 10;
int pageNo = ParamUtils.getIntParameter(request,"page",1);
list = downloadMgr.get(otherSQL,orderField,pageNo,pageSize);
int total = downloadMgr.getTotal(); 
boolean b=(total % pageSize ==0);
int pageCount=b?(total/pageSize):(total/pageSize +1);
if(pageNo>pageCount){
	pageNo=pageCount;
}
%>
<body  leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td >
      <table width="99%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td height="31" valign="top" background="images/title_bk_01.gif" style="padding-left:10px;padding-top:6px;">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="50%" style="color:#FFFFFF;font-size:13px;">
                  <b>知识库</b> -&gt; 
                  <b>软件下载列表</b>
                </td>
                <td width="50%" align="right" style="padding-right:10px;">&nbsp;
                  <span onclick="right_menu_clk('know_soft_add.jsp');" style="cursor:hand;color:#FFFFFF;font-size:12px;text-de--ation: underline;">添加下载软件</span>
                </td>
              </tr>
            </table>
          </td>
        </tr>
        <tr> 
          <td height="100" align="right" valign="top" style="padding-top:12px;padding-bottom:10px;padding-right:5px;"> 
            
            <form name="searchForm" method="post">
            <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
              <tr bgcolor="#EDEDF0"> 
                <td height="24" style="padding-left:10px;" colspan="4">
                  软件查找 --> &nbsp;&nbsp;
                  <select name="category_id" onchange="searchForm.submit();">
                    <option value="">全部分类</option>
                    <%
                    List cateList = cateMgr.get("","order_id");
                    if (cateList != null && cateList.size() > 0) {
                    	for(int j=0;j<cateList.size();j++) {
                    		DownCate cateItem = (DownCate)cateList.get(j);
                    %>
                    <option value="<%=cateItem.getId()%>"<%if (category_id.equals(cateItem.getId())){%> selected<%}%>><%=cateItem.getCategoryName()%></option>
                    <%
                    	}
                    }%>
                  </select> &nbsp;&nbsp;
                  软件名称：
                  <input name="keyval" type="text" class="inputbox" value="<%=keyval%>" size="20" maxlength="25">
                  <input type="button" name="button" value="搜　索" class="inputButton" onclick="clk_search();"> 
                </td>
              </tr>
             
            </table>
             </form>
            <%
            if (list != null && list.size() > 0) {
            	String bgColor[] = {"#EDEDF0","#D7D7DB"};
            	for(int i=0;i<list.size();i++) {
            		Download item = (Download)list.get(i);
            		String levelStar = "★★★★★★★★★★★★★★★";
            %>
            <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
              <tr bgcolor="#D7D7DB" align="center"> 
                <td height="24" width="45%"><b>软件所属分类[<%=item.getCate().getCategoryName()%>]</b></td>
                <td width="20%"><b>整理日期</b></td>
                <td width="20%"><b>软件大小</b></td>
                <td width="15%"><b>人气</b></td>
              </tr>
              <tr bgcolor="#EDEDF0"> 
                <td height="24" style="padding-left:4px;"><a href="knowledge_mgt/know_soft_detail.jsp?id=<%=item.getId()%>"><%=item.getSoftName()%></a></td>
                <td align="center"><%=item.getIssueTime()%></td>
                <td style="padding-right:4px;" align="right"><%=item.getSoftSize()%> K</td>
                <td style="padding-right:4px;" align="right"><%=item.getHit()%></td>
              </tr>
              <tr bgcolor="#FFFFFF"> 
                <td height="30" colspan="3" style="padding:4px 4px 4px 4px;"><%=item.getSoftDesc().replaceAll("\n","<br>")%></td>
                <td style="padding-left:5px;">
                  <font color="#FF0000"><%=levelStar.substring(0,item.getCommendLevel())%></font>
                </td>
              </tr>
              <tr bgcolor="#FFFFFF"> 
                <td height="24" style="padding-left:4px;" colspan="3">
                  <font color="#659E47">语言界面：</font> <%=item.getSoftLanguage()%> &nbsp;
                  <font color="#659E47">授权方式：</font> <%=item.getSoftType()%> &nbsp;
                  <font color="#659E47">运行平台：</font> <%=item.getOsType()%> &nbsp;
                </td>
                <td align="center">
                  <span onclick="clk_soft_show('<%=item.getId()%>');" style="cursor:hand;text-decoration: underline;">操作</span>
                </td>
              </tr>
            </table>
            <%	}%>
            <form name="pageForm" method="post">
            <table width="100%" border="0" cellpadding="0" cellspacing="0" background="images/page_img/page_bk.gif">
              
              <tr height="32" align="center" valign="bottom"> 
                <td width="5%">
                  <img src="images/page_img/page_tag_01.gif">
                  <input type="hidden" name="category_id" value="<%=category_id%>">
                  <input type="hidden" name="keyval" value="<%=keyval%>">
                </td>
                <td height="35" align="right" style="padding-right:10px;" valign="bottom" id="pannelPageInfo">&nbsp;</td>
              </tr>
              
            </table>
            </form>
            <script language="javascript">
            pannelPageInfo.innerHTML = getPageInfo(<%=total%>,<%=pageSize%>,<%=pageNo%>,5,'images/page_img','pageForm');
            </script>
            <%}else{%>
            <table width="95%" border="0" cellpadding="4" cellspacing="1" bgcolor="#FFFFFF">
              <tr> 
                <td height="60" align="center">目前没有找到软件信息!</td>
              </tr>
            </table>
            <%}%>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body>
</html>